package com.nbsaas.boot.order.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.time.LocalDate;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "订单统计", model = "订单统计")
@Entity
@Table(name = "bs_order_statistics")
@Comment("订单统计表")
public class OrderStatistics extends AbstractEntity {

    @Comment("统计日期")
    @FormField(title = "统计日期", sortNum = "1", grid = true, required = true, type = InputType.date)
    @Column(name = "stat_date", nullable = false)
    private LocalDate statDate;

    @Comment("店铺ID")
    @FormField(title = "店铺ID", sortNum = "2", grid = true, required = true)
    @Column(name = "shop_id", nullable = false)
    private Long shopId;

    @Comment("店铺名称")
    @FormField(title = "店铺名称", sortNum = "3", grid = true)
    @Column(name = "shop_name", length = 100)
    private String shopName;

    @Comment("订单总数")
    @FormField(title = "订单总数", sortNum = "4", grid = true, type = InputType.el_input_number)
    @Column(name = "order_count", nullable = false)
    private Integer orderCount = 0;

    @Comment("订单总金额")
    @FormField(title = "订单总金额", sortNum = "5", grid = true, type = InputType.el_input_number)
    @Column(name = "order_amount", nullable = false, precision = 12, scale = 2)
    private BigDecimal orderAmount = BigDecimal.ZERO;

    @Comment("实付总金额")
    @FormField(title = "实付总金额", sortNum = "6", grid = true, type = InputType.el_input_number)
    @Column(name = "pay_amount", nullable = false, precision = 12, scale = 2)
    private BigDecimal payAmount = BigDecimal.ZERO;

    @Comment("退款总金额")
    @FormField(title = "退款总金额", sortNum = "7", grid = true, type = InputType.el_input_number)
    @Column(name = "refund_amount", nullable = false, precision = 12, scale = 2)
    private BigDecimal refundAmount = BigDecimal.ZERO;

    @Comment("净收入")
    @FormField(title = "净收入", sortNum = "8", grid = true, type = InputType.el_input_number)
    @Column(name = "net_amount", nullable = false, precision = 12, scale = 2)
    private BigDecimal netAmount = BigDecimal.ZERO;

    @Comment("待付款订单数")
    @FormField(title = "待付款订单数", sortNum = "9", grid = true, type = InputType.el_input_number)
    @Column(name = "pending_pay_count", nullable = false)
    private Integer pendingPayCount = 0;

    @Comment("待发货订单数")
    @FormField(title = "待发货订单数", sortNum = "10", grid = true, type = InputType.el_input_number)
    @Column(name = "pending_delivery_count", nullable = false)
    private Integer pendingDeliveryCount = 0;

    @Comment("待收货订单数")
    @FormField(title = "待收货订单数", sortNum = "11", grid = true, type = InputType.el_input_number)
    @Column(name = "pending_receive_count", nullable = false)
    private Integer pendingReceiveCount = 0;

    @Comment("已完成订单数")
    @FormField(title = "已完成订单数", sortNum = "12", grid = true, type = InputType.el_input_number)
    @Column(name = "completed_count", nullable = false)
    private Integer completedCount = 0;

    @Comment("已取消订单数")
    @FormField(title = "已取消订单数", sortNum = "13", grid = true, type = InputType.el_input_number)
    @Column(name = "cancelled_count", nullable = false)
    private Integer cancelledCount = 0;

    @Comment("已退款订单数")
    @FormField(title = "已退款订单数", sortNum = "14", grid = true, type = InputType.el_input_number)
    @Column(name = "refunded_count", nullable = false)
    private Integer refundedCount = 0;

    @Comment("新增用户数")
    @FormField(title = "新增用户数", sortNum = "15", grid = true, type = InputType.el_input_number)
    @Column(name = "new_user_count", nullable = false)
    private Integer newUserCount = 0;

    @Comment("活跃用户数")
    @FormField(title = "活跃用户数", sortNum = "16", grid = true, type = InputType.el_input_number)
    @Column(name = "active_user_count", nullable = false)
    private Integer activeUserCount = 0;

    @Comment("平均客单价")
    @FormField(title = "平均客单价", sortNum = "17", grid = true, type = InputType.el_input_number)
    @Column(name = "avg_order_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal avgOrderAmount = BigDecimal.ZERO;

    @Comment("转化率")
    @FormField(title = "转化率", sortNum = "18", grid = true, type = InputType.el_input_number)
    @Column(name = "conversion_rate", nullable = false, precision = 5, scale = 2)
    private BigDecimal conversionRate = BigDecimal.ZERO;

    @Comment("统计类型")
    @FormField(title = "统计类型", sortNum = "19", grid = true, type = InputType.select)
    @Column(name = "stat_type", nullable = false)
    private Integer statType = 1;

    @Comment("备注")
    @FormField(title = "备注", sortNum = "20", type = InputType.textarea)
    @Column(name = "remark", length = 200)
    private String remark;
} 